<template>
  <el-tabs v-model="tabPaneVal" type="border-card" @tab-click="handleClick">
    <el-tab-pane label="企业资料" name="ShipmentEdit">
      <ShipmentEdit v-if="isShipmentEditShow" :parentData="parentData" />
    </el-tab-pane>
    <!-- <el-tab-pane label="开票信息管理" name="InvoiceMessage">
      <InvoiceMessage v-if="isInvoiceMessageShow" :parentData="parentData" />
    </el-tab-pane> -->
<!--    <el-tab-pane label="地址管理" name="CommonRouteInfo">-->
<!--      <CommonRouteInfo v-if="isCommonRouteInfoShow" :parentData="parentData" />-->
<!--    </el-tab-pane>-->
<!--    <el-tab-pane label="承运分组" name="VehicleTeam">-->
<!--      <VehicleTeam v-if="isVehicleTeamShow" :parentData="parentData" />-->
<!--    </el-tab-pane>-->
<!--    <el-tab-pane label="员工管理" name="ShipmentStaff">-->
<!--      <ShipmentStaff v-if="isShipmentStaffShow" :parentData="parentData" />-->
<!--    </el-tab-pane>-->
<!--    <el-tab-pane label="上游客户管理" name="UpstreamCustomer">-->
<!--      <UpstreamCustomer v-if="isUpstreamCustomerShow" :parentData="parentData" />-->
<!--    </el-tab-pane>-->
<!--    <el-tab-pane label="计价体系" name="PriceSystem">-->
<!--      <PriceSystem v-if="isPriceSystemShow" :parentData="parentData" />-->
<!--    </el-tab-pane>-->
  </el-tabs>
</template>

<script>
import ShipmentEdit from "./components/shipmentEdit.vue";
import InvoiceMessage from "./components/invoiceMessage/invoiceMessageList.vue";
import CommonRouteInfo from "./components/commonRouteInfo/commonRouteInfoList.vue";
import VehicleTeam from "./components/vehicleTeam/vehicleTeamList.vue";
import ShipmentStaff from "./components/shipmentStaff/shipmentStaffList.vue";
import UpstreamCustomer from "./components/upstreamCustomer/upstreamCustomerList.vue";
// import PriceSystem from "@/views/basicInfo/priceSystem/priceSystem.vue";
import { SelectAddress } from "@/api/orderform";
import { getListDict,  getShipperList } from "@/api/shipment";
export default {
  name: "EditShipmentCompanyForm",
  components: {
    ShipmentEdit,
    InvoiceMessage,
    CommonRouteInfo,
    VehicleTeam,
    ShipmentStaff,
    UpstreamCustomer,
    // PriceSystem
  },
  data() {
    return {
      companyCode: '',
      parentData: {
        isCompany: true,
        areaOptions: [],
        goodsTypeList: [],
        typeOptions: [],
        vehicleDictList: [],
        bankOptions: [],
        receiverUserCodeOptions: [],
        upstreamCustomerList: []
      },
      tabPaneVal: "ShipmentEdit",
      isShipmentEditShow: true,
      isInvoiceMessageShow: false,
      isCommonRouteInfoShow: false,
      isVehicleTeamShow: false,
      isShipmentStaffShow: false,
      isUpstreamCustomerShow: false,
      // isPriceSystemShow: false,
    };
  },
  created() {
    this.companyCode = this.$route.query.code ? this.$route.query.code : "";
    // 省市县
    SelectAddress().then(response => {
      this.parentData.areaOptions = response.data.records;
    });
    // 收票人选项
    getShipperList({ staffTypes: "1,4,6", companyCode: this.companyCode }).then(response => {
      this.parentData.receiverUserCodeOptions = response.data.records;
    });
    // 上游客户
    getShipperList({ staffType: '5', companyCode: this.companyCode }).then(response => {
      this.parentData.upstreamCustomerList = response.data.records
    });
    // 货物类型字典
    // getGoodsTypeDict({ parentCode: "goodsBigType" }).then(response => {
    //   this.parentData.goodsTypeList = response.data.records;
    // });
    // 开票方式、车型、开户银行
    getListDict({ types: "billingType,vehicleClassification,bank" }).then(
      response => {
        this.parentData.typeOptions = response.data.filter(
          item => item.type === "billingType"
        )[0]["dictList"];
        this.parentData.vehicleDictList = response.data.filter(
          item => item.type === "vehicleClassification"
        )[0]["dictList"];
        this.parentData.bankOptions = response.data.filter(
          item => item.type === "bank"
        )[0]["dictList"];
      }
    );
  },
  methods: {
    handleClick(tab, event) {
      this[`is${tab.name}Show`] = true;
      // 重新获取 上游客户
      if (tab.name === 'UpstreamCustomer') {
        getShipperList({ staffType: '5', companyCode: this.companyCode }).then(response => {
          this.parentData.upstreamCustomerList = response.data.records
        });
      }
    }
  }
};
</script>
